package com.spzx.pay.config;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.spzx.pay.utils.AlipayProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 读取配置文件AlipayProperties中内容
 * <p>
 * Project: spzx-parent
 * Package: com.spzx.pay.config
 * Version: 1.0
 * <p>
 * Created by  wangjiaxin  on 2024/5/5 下午9:30
 */
@Configuration
public class AlipayConfiguration {
    @Autowired
    private AlipayProperties alipayProperties;

    /**
     * 支付宝服务接口
     *
     * @return
     */
    @Bean
    public AlipayClient alipayClient() {
        AlipayClient alipayClient = new DefaultAlipayClient(alipayProperties.getAlipayUrl(),
                alipayProperties.getAppId(),
                alipayProperties.getAppPrivateKey(),
                AlipayProperties.format,
                AlipayProperties.charset,
                alipayProperties.getAlipayPublicKey(),
                AlipayProperties.sign_type);
        return alipayClient;
    }
}
